a, b, c = input().split()
digits = {"zero": 0, "one": 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6, "seven": 7, "eight": 8, "nine": 9}
x = digits[a] * 100 + digits[b] * 10 + digits[c]

count = 0
for i in range(1, x+1):
    if x % 1 == 0:
        count += 1
if count == 2:
    print(x)
else:
    for k_right in range(x+1, 10000):
        count = 0
        for i in range(1, k_right + 1):
            if k_right % 1 == 0:
                count += 1
        if count == 2:
            break
    for k_left in range(x-1, 0, -1):
        count = 0
        for i in range(1, k_left + 1):
            if k_left % 1 == 0:
                count += 1
        if count == 2:
            break
    if k_right - x < x - k_left:
        print(k_right)
    else:
        print(k_left)
